//
//  AppMarcos.h
//  CFFinanceProject
//
//  Created by chunfeng on 2018/4/9.
//  Copyright © 2018年 xiaowen. All rights reserved.
//

#ifndef AppMarcos_h
#define AppMarcos_h

/**
 @abstract 获取本机屏幕的宽度.
 **/
static inline CGFloat DEF_SCREEN_WIDTH()
{
    return [UIScreen mainScreen].bounds.size.width;
}
/**
 @abstract 获取本机屏幕的高度.
 **/
static inline CGFloat DEF_SCREEN_HEIGHT()
{
    return [UIScreen mainScreen].bounds.size.height;
}

/**
 @abstract 获取去导航控制器64时屏幕高度.
 **/
static inline CGFloat DEF_SCREEN_HASNAV_HEIGHT()
{
    return [UIScreen mainScreen].bounds.size.height - 64;
}

/**
 @abstract 获取本机的操作系统版本.
 **/
static inline NSString* DEF_DEVICE_SYSTEM_VERSION()
{
    return [[UIDevice currentDevice] systemVersion];
}

/**
 @abstract 获取本机上的软件版本.
 **/
static inline NSString * DEF_APP_VERSION()
{
    return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
}

/**
 @abstract 根据size来获取文字大小.
 **/
static inline UIFont * DEF_UIFONT_FROM_SIZE(CGFloat size)
{
    return [UIFont systemFontOfSize:size];
}

/**
 @abstract 根据Hex值来获取UICOLOR.
 **/
static inline UIColor * DEF_UICOLOR_FROM_HEX(NSInteger hex)
{
    return [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16))/255.0 green:((float)((hex & 0xFF00) >> 8))/255.0 blue:((float)(hex & 0xFF))/255.0 alpha:1.0];
}
/**
 @abstract 根据RGB值来获取UICOLOR.
 **/
static inline UIColor * DEF_UICOLOR_FROM_RGB(CGFloat r,CGFloat g,CGFloat b,CGFloat a)
{
    return [UIColor colorWithRed:r/255.f green:g/255.f blue:b/255.f alpha:a];
}


/**
 @abstract 根据name来获取图片.
 **/
static inline UIImage * DEF_UIIMAGE_FROM_NAME(NSString *name)
{
    return [UIImage imageNamed:name];
}


/**
 @abstract 根据path和type来获取图片.
 @param path 需要查找的文件路径.
 @param type 需要查找的文件类型.(PNG,JPG)
 **/
static inline UIImage * DEF_UIIMAGE_FROM_PATH_AND_TYPE(NSString *path,NSString *type)
{
    return [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:path ofType:type]];
}


/**
 @abstract 判断本机是否为iPhone4或者iPhone4s.
 **/
static inline BOOL DEF_iPhone4()
{
    return [UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO;
}
/**
 @abstract 判断本机是否为iPhone5或者iPhone5s.
 **/
static inline BOOL DEF_iPhone5()
{
    return [UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO;
}

static inline BOOL DEF_isStorePad()
{
    BOOL  is5 = [UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO;
    BOOL isPad;
    NSString *deviceType = [UIDevice currentDevice].model;
    
    if([deviceType isEqualToString:@"iPad"]) {
        isPad = YES;
    }else{
        isPad = NO;
    }
    if (isPad || is5) {
        return YES;
    }else{
        return NO;
    }
    
}

static inline BOOL DEF_isPad()

{
    
    NSString *deviceType = [UIDevice currentDevice].model;
    
    if([deviceType isEqualToString:@"iPhone"]) {
        
        //iPhone
        
        return NO;
        
    }
    
    else if([deviceType isEqualToString:@"iPod touch"]) {
        
        //iPod Touch
        
        return NO;
        
    }
    
    else if([deviceType isEqualToString:@"iPad"]) {
        
        //iPad
        
        return YES;
        
    }
    
    return NO;
    
}


//#define  StatusHeight      iPhoneX()?44: 20





static inline BOOL DEF_iPhoneX()
{
    return [UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO;
}



static inline CGFloat DEF_StatusHeight()
{
    return DEF_iPhoneX()?44: 20;
}

static inline CGFloat DEF_NAV_HEIGHT()
{
    return DEF_iPhoneX()? 88: 64;
}

static inline CGFloat DEF_NOTX_Status_20()
{
    return DEF_iPhoneX()? 0: 20;
}

static inline CGFloat DEF_NAV_MORE_44_HEIGHT()
{
    return DEF_iPhoneX()? 44: 0;
}

static inline CGFloat DEF_VIDEO_NAV_MORE_HEIGHT()
{
    if(DEF_isPad()){
        return  44;
    }
    return DEF_iPhoneX()? 34: 0;
}

static inline CGFloat DEF_IPAD_NAV_MORE_HEIGHT()
{
    return DEF_isPad()? 20: 0;
}
static inline CGFloat DEF_NAV_MORE_HEIGHT()
{
    return DEF_iPhoneX()? 24: 0;
}

static inline CGFloat DEF_TABBAR_HEIGHT()
{
    return DEF_iPhoneX()? 83 : 49;
}

static inline CGFloat DEF_TABBAR_HEIGHT_MORE()
{
    return DEF_iPhoneX()? 83 : 0;
}

static inline CGFloat DEF_TABBAR_MORE_HEIGHT()
{
    return DEF_iPhoneX()? 34 : 0;
}

/**
 @abstract 判断本机是否为iPhone6、iPhone7.
 **/
static inline BOOL DEF_iPhone7()
{
    return [UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO;
}
/**
 @abstract 判断本机是否为iPhone6Plus、iPhone7Plus.
 **/
static inline BOOL DEF_iPhone7Plus()
{
    return [UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO;
}


/**
 @abstract 获取object所有的子类.
 **/
//static inline NSArray * DEF_GET_ALL_SUBCLASS_OF_OBJECT(id object){
//    Class myClass = [object class];
//    NSMutableArray *mySubclasses = [NSMutableArray array];
//
//    unsigned int numOfClasses;
//    Class *classes = objc_copyClassList(&numOfClasses);
//    for (unsigned int ci = 0; ci < numOfClasses; ci++) {
//        Class superClass = classes[ci];
//        do {
//            superClass = class_getSuperclass(superClass);
//        } while (superClass && superClass != myClass);
//
//        if (superClass)
//            [mySubclasses addObject: classes[ci]];
//    }
//    free(classes);
//    return mySubclasses;
//}


/**
 @abstract 过滤转化掉nil或NULL的字符串.
 **/
static inline NSString * DEF_FilterString(NSString * str){
    return (str == nil || [str isKindOfClass:[NSNull class]] || str.length == 0)? @"":str;
}


/**
 @abstract 字典绑定变量，生成变量名为键，变量值为值的字典.
 **/

#define NSDictionaryBindParameters(...)   NSDictionaryOfVariableBindings(__VA_ARGS__)



#endif /* AppMarcos_h */
